package com.fengmi.mapper;

import com.fengmi.entity.SysPermission;
import com.fengmi.vo.CascadeVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author 123
 * @Date 2022/2/10 11:22
 * @Version 1.0
 */

public interface SysPermissionMapper {
    // 查询所有权限信息，加入条件查询
    public List<SysPermission> findPermissionByWhere(SysPermission sysPermission);

    // 查询权限及其子类权限
    public List<CascadeVO> findPermissionCascade();

    // 添加权限
    @Insert("insert into sys_permission (perm_code,perm_name,link_url,parent_perm,perm_desc,`show`) " +
            "values (#{permCode},#{permName},#{linkUrl},#{parentPerm},#{permDesc},#{show})")
    public int insertPermission(SysPermission sysPermission);

    //通过父id 查询子类权限集合
    @Select("SELECT * FROM sys_permission WHERE parent_perm =#{pid} ORDER BY perm_code")
    public List<SysPermission> findChildrenPermissionByParentId(String pid);

    // 修改权限信息
    public int updatePermissionInfo(SysPermission sysPermission);

    // 通过权限编号删除权限信息
    @Delete("delete from sys_permission where perm_code = #{permCode}")
    public int deletePermissionByPermCode(String permCode);
}

